<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>事件的基本使用</title>
  <!-- 引入Vue -->
  <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
  <!-- 准备好一个容器 -->
  <div id="root">
    <h2>欢迎来到{{name}}学习</h2>
    <button v-on:click="showInfo1">点我提示信息1</button>
    <button @click="showInfo2($event)">点我提示信息2</button>
  </div>
</body>

<script type="text/javascript">

  const vm = new Vue({
    el: '#root',
    data: {
      name: '尚硅谷'
    },
    methods: {
      showInfo1(event) {
        console.log(event.target.innerText);
        console.log(this); //此处的this 是vm
        // alert('你好')
      },
      showInfo2() {
        alert('蔡徐坤')
      }
    },
  })
</script>

</html>